/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            websiteAccessLogManageInfo: {
                websiteAccessLogs: [],
                total: 0,
                records: 1,
                moreCondition: false,
                logId: '',
                conditions: {
                    logId: '',
                    ip: '',
                    accessUrl: '',
                    loginState: '',
                }
            }
        },
        _initMethod: function () {
            $that._listWebsiteAccessLogs(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('websiteAccessLogManage', 'listWebsiteAccessLog', function (_param) {
                $that._listWebsiteAccessLogs(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listWebsiteAccessLogs(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listWebsiteAccessLogs: function (_page, _rows) {

                $that.websiteAccessLogManageInfo.conditions.page = _page;
                $that.websiteAccessLogManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.websiteAccessLogManageInfo.conditions
                };

                //发送get请求
                vc.http.apiGet('websiteAccessLog.listWebsiteAccessLog',
                    param,
                    function (json, res) {
                        var _websiteAccessLogManageInfo = JSON.parse(json);
                        $that.websiteAccessLogManageInfo.total = _websiteAccessLogManageInfo.total;
                        $that.websiteAccessLogManageInfo.records = _websiteAccessLogManageInfo.records;
                        $that.websiteAccessLogManageInfo.websiteAccessLogs = _websiteAccessLogManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.websiteAccessLogManageInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddWebsiteAccessLogModal: function () {
                vc.emit('addWebsiteAccessLog', 'openAddWebsiteAccessLogModal', {});
            },
            _openEditWebsiteAccessLogModel: function (_websiteAccessLog) {
                vc.emit('editWebsiteAccessLog', 'openEditWebsiteAccessLogModal', _websiteAccessLog);
            },
            _openDeleteWebsiteAccessLogModel: function (_websiteAccessLog) {
                vc.emit('deleteWebsiteAccessLog', 'openDeleteWebsiteAccessLogModal', _websiteAccessLog);
            },
            _queryWebsiteAccessLogMethod: function () {
                $that._listWebsiteAccessLogs(DEFAULT_PAGE, DEFAULT_ROWS);

            },
            _moreCondition: function () {
                if ($that.websiteAccessLogManageInfo.moreCondition) {
                    $that.websiteAccessLogManageInfo.moreCondition = false;
                } else {
                    $that.websiteAccessLogManageInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
